package com.example.demohello.mapper;


import com.example.demohello.entity.Course;
import com.example.demohello.vo.CourseRequestBo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CourseMapper {

    @Insert("insert into course(course_id, course_name, teacher_id) values( #{courseId}, #{courseName}, #{teacherId})")
    Integer addCourse(Course course);

    @Delete("delete from course  where course_id =  #{courseId}")
    Integer deleteCourse(Integer courseId);


    @Select("select * from course")
    @Results({
            @Result(property = "courseId",column = "course_id"),
            @Result(property = "courseName",column = "course_name"),
            @Result(property = "teacherId",column = "teacher_id"),
    })
    List<Course> selectCourse();

    @Select("select * from course where course_id =  #{courseId}")
    @Results({
            @Result(property = "courseId",column = "course_id"),
            @Result(property = "courseName",column = "course_name"),
            @Result(property = "teacherId",column = "teacher_id"),
    })
    Course selectOneCourse(Integer courseId);



    @Update("update course set course_name = #{courseName},teacher_id = #{teacherId} where course_id =  #{courseId}")
    Integer updateCourse(Course course);


    List<Course> selectForCourseList(CourseRequestBo requestBo);


    Integer selectCountCourse(CourseRequestBo requestBo);
}
